﻿<?php
include 'test_header.php';

class test_user_judge_process extends UnitTestCase{
	
	private $db ; 

	function setUp(){
		$this->db = db_connect();

		$sql = "
CREATE TABLE  `result` (
`code_file_name` VARCHAR( 64 ) NOT NULL ,
`problem_no` INT NOT NULL ,
`username` VARCHAR( 256 ) NOT NULL ,
`result` VARCHAR( 1024 ) NOT NULL ,
`judge_time` DATETIME NOT NULL ,
`time_spend` VARCHAR( 128 ) NOT NULL ,
`memory_spend` VARCHAR( 128 ) NOT NULL
) ENGINE = INNODB";

       		$res = $this->db->query( $sql );
	}

	function tearDown(){
		
		$sql = "drop table `result`";

		$res = $this->db->query( $sql );
	
	}
	function test_do_judge(){
		
		$db = db_connect();
		$temp_file_name = './code/test.c' ;

		$judge_process = new judge_process( $db );
		$result = $judge_process->do_judge( $temp_file_name );
		$this->assertTrue( $result );
	}


}
	

$test = new test_user_judge_process();
$test->run( new HtmlReporter() );

